﻿Imports System.Windows.Forms

Public Class SelectQuizDialog
    Private Sub SelectQuizDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListBox1.Items.Clear()
        For Each File As String In IO.Directory.GetFiles("Quiz Files\")
            ListBox1.Items.Add(File.Remove(0, 11))
        Next
    End Sub

    Private Sub SelectButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SelectButton.Click
        DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub UploadButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UploadButton.Click
        Dim FileName As String = InputBox("Enter File Path")
        If Not FileName = "" Then
            Dim _FileName As String = ""
            For i = FileName.Length - 1 To 0 Step -1
                If FileName(i) = "/" Then Exit For
                If FileName(i) = "\" Then Exit For
                _FileName = _FileName.Insert(0, FileName(i))
            Next
            IO.File.Copy(FileName, "Quiz Files\" & _FileName)
        End If
        ListBox1.Items.Clear()
        For Each File As String In IO.Directory.GetFiles("Quiz Files\")
            ListBox1.Items.Add(File.Remove(0, 11))
        Next
    End Sub
End Class
